package wjh.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import wjh.mapper.wyDepartmentMapper;
import wjh.pojo.Department;

import java.util.List;

@Service
public class wyDepartmentServiceImpl implements wyDepartmentService {
    @Autowired
    private wyDepartmentMapper departmentMapper;
    @Override
    public List<Department> like(String likename) {
        List<Department> like = departmentMapper.like(likename);
        return like;
    }

    @Override
    public void addDepartment(Department department) {
        departmentMapper.addDepartment(department);
    }




    @Override
    public void deleteDepartmentByid(String ids) {
        String[] idArray = ids.split("-");
        for (String id : idArray) {
            if (!id.isEmpty()) {
                departmentMapper.deleteDepartmentByid(Integer.parseInt(id));
            }
        }

    }

    @Override
    public Department findDepartmentById(int id) {
        return departmentMapper.findDepartmentById(id);
    }

    @Override
    public void updateDepartment(Department department) {
        departmentMapper.updateDepartment(department);
    }

    @Override
    public int findIdByName(String department) {
      int detId =  departmentMapper.findIdByName(department);
        return detId;
    }


    @Override
    public List<Department> findAll() {
        return departmentMapper.findAll();
    }

}
